package org.wx.io.netty.rpc.client;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import org.wx.io.netty.rpc.codec.RpcDecoder;
import org.wx.io.netty.rpc.codec.RpcEncoder;

/**
 * @description: 客户端handler初始化
 * @author: wangxun
 * @createDate: 2021/2/23
 * @version: 1.0
 */
public class RpcClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline()
                .addFirst("rpc encoder", new RpcEncoder())
                .addLast("Logger",new LoggingHandler(LogLevel.INFO))
                .addLast("rpc decoder",new RpcDecoder())
                .addLast("rpc client handler",new RpcClientHandler());

    }
}
